//
//  PSLeningradCalculatorTests.m
//  PrefCore
//
//  Created by Sergey on 3/4/14.
//  Copyright (c) 2014 Play-on-smart. All rights reserved.
//

#import <XCTest/XCTest.h>
#import "PSCalculator.h"

#define TARGET_POOL (PSScoreValue)30

@interface PSLeningradCalculatorTests : XCTestCase {
    PSCalculator *calc;
    PSGame *game;
    PSGameSettings *settings;
}

@end

@implementation PSLeningradCalculatorTests

-(void)setUp {
    [super setUp];
    calc = [PSCalculator calculatorForGameFlavor:kGameFlavorLeningrad];
    NSUserDefaults *ud = [NSUserDefaults standardUserDefaults];
    [PSGameSettings clearUserDefaults:ud];
    [ud synchronize];
    settings = [PSGameSettings settingsFromUserDefaults:ud];
    settings.poolSize = TARGET_POOL;
    game = [[PSGame alloc] init];
}

-(void)testInit {
    XCTAssertNotNil(calc);
}

-(void)testIsClosedFalse {
    for (PSPlayer *p in game.players) {
        XCTAssertFalse([calc isClosed:p game:game settings:settings]);
    }
}

-(void)testIsClosedTrue {
    for (PSPlayerId p = 0 ; p != PS_GAME_PLAYERS ; p++) {
        [[game scoreForPlayerId:p].pool addValue:TARGET_POOL];
    }
    for (PSPlayer *p in game.players) {
        XCTAssertTrue([calc isClosed:p game:game settings:settings]);
    }
}

@end
